package com.lq.file.filemanager.util;

import com.lq.file.filemanager.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @program: file-manager
 * @description:
 * @author: LQ
 * @create: 2021-08-07 10:56
 */
@Component
public class FileServiceUtil {

    @Value("${file.server.type}")
    private String fileServiceType;

    @Autowired
    @Qualifier("FtpFileService")
    private FileService ftpFileService;

    @Autowired
    @Qualifier("FastdfsFileService")
    private FileService fastdfsFileService;


    public FileService getFileService() {
        switch (fileServiceType) {
            case "ftp": {
                return ftpFileService;
            }
            case "fastdfs": {
                return fastdfsFileService;
            }
            default: {
                return ftpFileService;
            }
        }
    }
}
